<& /Elements/Header, Title=>"On-Call Tracker" &>
<& /OnCall/Elements/Tabs,
    current_toptab => '/OnCall/index.html',
    Title => "Modify Group" &>

<& /Elements/ListActions, actions => \@Actions &>


<H2><% $group->Name %></H2>
<FORM METHOD=POST ACTION="index.html" ENCTYPE="multipart/form-data">
<INPUT Type="hidden" Name="group" Value="<%$group->id%>">
% my $content = $group->FirstAttribute('GroupPhone');
% $content = ref($content) ? $content->Content : $content;
<H3>Group Phone: <INPUT Name="GroupPhone" SIZE=20 VALUE="<%$content%>"></H3>

<table>
<tr>
<th>User</th>
<th>Primary</th>
<th>Secondary</th>
<th>Member</th>
<th>Team Lead</th>
</tr>
% foreach my $user (@users) {
<tr align="center">
<td align="left"><%$user->RealName%> (<%$user->Name%>)</td>
<td><INPUT type="radio" Name="User-<%$user->id%>" Value="primary"   <% $group->IsPrimaryOnCall($user) ? 'checked="1"' : '' %></td>
<td><INPUT type="radio" Name="User-<%$user->id%>" Value="secondary" <% $group->IsSecondaryOnCall($user) ? 'checked="1"' : '' %></td>
<td><INPUT type="radio" Name="User-<%$user->id%>" Value="member"></td>
<td><INPUT type="checkbox" Name="User-<%$user->id%>-Lead" Value="teamlead" <% $group->IsTeamLead($user) ? 'checked="1"' : '' %></td>
</tr>
% }
</table>

<& /Elements/Submit, Label => loc('Save Changes'), Caption => loc("If you've updated anything above, be sure to"), color => "#993333" &>
</FORM>
<%INIT>

my @users;

my $group = RT::Group->new($session{CurrentUser});
my ($rv, $msg) = $group->Load($id);

unless ($group->CurrentUserHasRight('AdminOnCall')) {
    $m->comp("/Elements/Error", Why => 'No permission to modify OnCall information for group '. $group->Name);
    $m->abort;
}

my $members = $group->MembersObj;
$members->LimitToUsers;
while (my $groupmember = $members->Next) {
    push @users, $groupmember->MemberObj->Object;
}

</%INIT>
<%ARGS>
$id
@Actions => undef
</%ARGS>
